import { getExtensionConfig, getFrameworkConfig } from '../utils';
import { IConfigItem, IBuildPlugin } from '../../@types/packages/builder/@types/public/build-plugin';

const econfig = getExtensionConfig();

const fconfig = getExtensionConfig();
let ModuleItems:{ [key:string]:IConfigItem } = {};
let ModuleDefaults:{ [key:string]:boolean } = {};
for(let mname in fconfig.modules){
	let module = fconfig.modules[mname];
	if(!module.baseModule){
		ModuleItems[mname] = {
			description : module.description,
			label : mname,
			render: {
				ui: 'ui-checkbox',
			},
		}
		ModuleDefaults[mname] = module.keepDefault;
	}
}

export const configs: Record<string, IBuildPlugin> = {
    '*': {
        hooks: './hooks',
        options: {
			confuse : {
				description: `i18n:${econfig.name}.framework-confuse-desc`,
                label: `i18n:${econfig.name}.framework-confuse`,
                default: false,
                render: {
                    ui: 'ui-checkbox',
                },
			},
            clip: {
                description: `i18n:${econfig.name}.framework-clip-desc`,
                label: `i18n:${econfig.name}.framework-clip`,
                default: true,
                render: {
                    ui: 'ui-checkbox',
                },
            },
            clipMethod: {
                description: `i18n:${econfig.name}.clip-method-desc`,
                label: `i18n:${econfig.name}.clip-method`,
                default: 'auto',
                render: {
                    ui: 'ui-select',
                    items: [
                        {
                            label: `i18n:${econfig.name}.auto-clip`,
                            value: 'auto',
                        },
                        {
                            label: `i18n:${econfig.name}.custome-clip`,
                            value: 'custom',
                        },
                    ],
                },
            },
            keepModules: {
				label: `i18n:${econfig.name}.custome-clip-modules`,
				type: 'object',
                attributes: {
                    class: 'wrap',
                },
                default: ModuleDefaults,
                itemConfigs: ModuleItems,
            },
        },
    },
};
